﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebService.aspx.cs" Inherits="ProjectStudy.WebService.webService" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#btn1").click(function () {
                $.ajax({
                    type: "post",
                    url: "WebService1.asmx/HelloWorld",
                    contentType: "application/json",
                    dataType:"json",
                    success: function (data) {
                        alert(data.d);
                    }
                });
            });

            $("#btn5").click(function () {
                $.ajax({
                    type: "post",
                    url: "WebService1.asmx/HelloInt",
                    contentType: "application/json",
                    success: function (data) {
                        alert(data.d);
                    }
                });
            });

            $("#btn6").click(function () {
                $.ajax({
                    type: "post",
                    url: "WebService1.asmx/HelloBool",
                    contentType: "application/json",
                    success: function (data) {
                        alert(data.d);
                    }
                });
            });

            $("#btn7").click(function () {
                $.ajax({
                    type: "post",
                    url: "WebService1.asmx/HelloFloat",
                    contentType: "application/json",
                    success: function (data) {
                        alert(data.d);
                    }
                });
            });

            $("#btn2").click(function () {
                $.ajax({
                    type: "post",
                    url: "WebService1.asmx/HelloString",
                    contentType: "application/json",
                    data: "{ 'name': 'Fly' }",
                    dataType: "json",
                    success: function (data) {

                        alert(data.d);
                    }
                });
            });

            $("#btn3").click(function () {
                $.ajax({
                    type: "post",
                    url: "WebService1.asmx/CreateArray",
                    contentType: "application/json",
                    data: "{'i':5}",
                    dataType: "json",
                    success: function (data) {
                        alert(data.d);
                    }
                });
            });

            $("#btn4").click(function () {
                $.ajax({
                    type: "post",
                    url: "WebService1.asmx/GetClassInfoXML",
                    dataType: "xml",
                    success: function (data) {
                        var tr = "<tr align='center' style='background:#0094ff;color:white'><td>班级id</td><td>班级名称</td><td>班级描述</td><td>是否删除</td></tr>";
                        $(data).find("Table").each(function () {
                            tr += "<tr><td>" + $(this).find("id").text() + "</td><td>" + $(this).find("ClassName").text() + "</td><td>" + $(this).find("ClassDesc").text() + "</td><td>" + $(this).find("IsDel").text() + "</td></tr>";
                        });
                        $("#tb1").html(tr);
                    },
                    error: function (result) {
                        alert("err");
                    }
                });
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <input  type="button" id="btn1" value="调用无参webService返回字符串"/>
    <br />
    <input  type="button" id="btn5" value="调用无参webService返回整型"/>
    <br />
    <input  type="button" id="btn6" value="调用无参webService返回布尔型"/>
    <br />
    <input  type="button" id="btn7" value="调用无参webService返回单精度"/>
    <br />
    <input  type="button" id="btn2" value="调用有参webService返回字符串"/>
    <br />
    <input  type="button" id="btn3" value="调用无参webService返回ArrayList"/>
    <br />
    <input  type="button" id="btn4" value="调用无参webService返回DataSet(XML)"/>
        <br />
        <br />
        <asp:TextBox ID="TextBox1" runat="server" Height="78px" Width="307px" TextMode="MultiLine"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="WebService返回Student类" 
            onclick="Button1_Click" style="height: 21px" />
    <br />
    <table id="tb1" border="1" cellpadding="0" cellspacing="0">
      
    </table>

    
    </div>
    </form>
</body>
</html>
